//
//  dh11.h
//  wireless_sensor
//
//  Created by fukai on 2018/11.
//  Copyright © 2018年 赛博智能车实验室. All rights reserved.
//

#ifndef dh11_h
#define dh11_h


//延时函数
#include "tick_timer.h"
#define DELAY_MS(x)		DelayMs(x)
#define DELAY_US(x)		DelayUs(x)

//定义信号线通道以及引脚
#define DHT11_RCC			RCC_APB2Periph_GPIOA
#define DHT11_GPIO			GPIOA
#define DHT11_Pin			GPIO_Pin_0


//数据线输入输出方向设置
#define DHT11_DATA_IN()  	DHT11DataPinInput()
#define DHT11_DATA_OUT() 	DHT11DataPinOutput()

//主机发送时，时钟线和数据线的电平
#define DHT11_H()		GPIO_SetBits(DHT11_GPIO,DHT11_Pin)
#define DHT11_L()		GPIO_ResetBits(DHT11_GPIO,DHT11_Pin)

//主机读取数据线状态
#define DHT11_READ()		GPIO_ReadInputDataBit(DHT11_GPIO,DHT11_Pin)


//数据信息结构体
typedef struct
{
	unsigned char temperature;
	unsigned char humidity;
}DHT11MessageNode;


unsigned char DHT11Init(void);	
unsigned char DHT11ReadData(unsigned char *temp, unsigned char *humi);//从DHT11读取一次数据

extern DHT11MessageNode DHT11Message;

#endif


